import dt from '@dt/dt'
import houseOpt from '@/biz/option/house.js'
import toolMgr from '@/biz/base/tool.js'

let orgs = []

function organization() {
  let opt = {
    key: 'orgId',
    title: '所属组织',
    tree: {
      options: orgs,
    }
  }
  toolMgr.organization(2).then(res => {
    orgs = res
    opt.tree.options = orgs
  })
  return opt
}

function status(name) {
  return name === 'levelApprovalManager' ? [{
    key: 'state',
    title: '状态',
    placeholder: '全部',
    select: {
      options: dt.dictInfo().processAuditStatus
    }
  }] : []
}

function options(name) {
  return [
    organization(),
    houseOpt.create({
      to: (info) => {
        return {
          housesId: info.housesId
        }
      }
    }),
    ...status(name)
  ]
}

export default {
  options
}
